//
//  ViewController.m
//  倒计时按钮
//
//  Created by Adiljan on 2017/1/11.
//  Copyright © 2017年 Adiljan. All rights reserved.
//

#import "ViewController.h"
#import "CountdownButton.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    
    CountdownButton *btn = [[CountdownButton alloc] initWithFrame:CGRectMake(85, 150, 80, 20)];
    [btn setClickBlock:^{
        // 模拟网络请求时间 延迟了一秒
        // 真实项目 点击按钮之后发请求 请求成功后开始计时 到时候去掉 这个延迟方法
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [btn getCode:^{
                NSLog(@"Adiljan===>完成");
            }];
            
        });
    }];
    [self.view addSubview:btn];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
